package lc;
import java.util.Arrays;
import java.util.concurrent.atomic.AtomicInteger;

import org.junit.*;
public class Ex189 {
    class Solution {
        public void rotate(int[] nums, int k) {
            int n = nums.length;
            reverse(nums, 0, n);
            reverse(nums, 0, k);
            reverse(nums, k, n - k);
            AtomicInteger i = new AtomicInteger(0);
            i.incrementAndGet();
        }
    
        public void reverse(int[] nums, int start, int len) {
            for (int i = 0; i < len / 2; i++) {
                swap(nums, start + i, start + len - i - 1);
            }
        }
    
        public void swap(int[] nums, int i, int j) {
            int tmp = nums[i];
            nums[i] = nums[j];
            nums[j] = tmp;
        }
    }

    @Test
    public void test() {
        Solution s = new Solution();
        int[] nums = new int[]{1};
        s.rotate(nums, 1);
        System.out.println(Arrays.toString(nums));
        
    }
}
